<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//测试控制器
class IndaxController extends Controller{
	        
		public function index(){
		    $gid = Q('get.gid',0,'intval');
			//实例化商品表
		    $GoosData=new \Common\Model\Goods;
		   //获得商品表的所有数据
		    $GoodsData=$GoosData->where("gid = {$gid}")->get();
		   //分配到模板
//		    p($GoodsData);
		    View::with('GoodsData',$GoodsData);
			$data=Cart::getAllData(); 
           //分配到模板
            p($_SESSION);
            View::with('data',$data);
		    View::make();
	}
		/**
	 * 添加购物车请求地址
	 */		
	public function ajaxAddCart(){
			$data = array(
				'id'    	=> Q('post.id',0,'intval'),
				'name'  	=> Q('post.name',''),
				'num'	 	=> Q('post.num',0,'intval'),				
				'price' 	=> Q('post.price',0,'intval'),
				'options'   =>array(
								'color'	  => Q('post.color',''),
								'size'    => Q('post.size',''),							
							    ),
		        );
		
		
		Cart::add($data);	
		 
     }
	 public function del(){
      //删除session
//		session_unset();
      //摧毁session
//		session_destroy();
		$_SESSION['cart']['goods']=array(); 
		
		View::ajax(1);
    }
}